package logic

import (
	"context"
	"novel/novelrpc/novelrpc"

	"novel/api/internal/svc"
	"novel/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type BookShelfDelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewBookShelfDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BookShelfDelLogic {
	return &BookShelfDelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *BookShelfDelLogic) BookShelfDel(req *types.BookShelfDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	data, err := l.svcCtx.NovelRpc.BookShelfDel(l.ctx, &novelrpc.BookShelfDelRequest{
		UserId:  req.UserId,
		NovelId: req.NovelId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "下架书架成功",
		Data:    data,
		Code:    200,
	}, nil
}
